import { defineApis } from '@/utils/api'

// 查询菜单树
const getMenuTree = {
  url: "/menu",
  method: "get",
};

//同步菜单
const syncMenu = {
  url: "/menu",
  method: "post",
};

//新增菜单项
function addMenuItem(params?: Record<string, any>) {
  return {
    url: "/menu-item",
    method: "post",
    params
  }
}

//修改菜单项
const updateMenuItem = {
  url: "/menu-item",
  method: "put",
};

//删除菜单
function removeMenuItem(id: number) {
  return {
    url: `/menu-item/${id}`,
    method: "DELETE",
  };
}

//查询菜单页面下的接口
const getMenuPageApis = {
  url: "/menu-item/api",
  method: "get",
};

//分组查询菜单树，包含菜单页面下的接口
function getMenuApiTree(group: string) {
  return {
    url: "/menu-item/api-tree",
    method: "get",
    params: {
      group
    }
  }
}

//查询菜单组
const getMenuGroups = {
  url: "/menu-group",
  method: "get",
};

//新增菜单组
const addMenuGroup = {
  url: "/menu-group",
  method: "post",
};



export default defineApis('admin', {
  getMenuTree,
  syncMenu,
  addMenuItem,
  updateMenuItem,
  removeMenuItem,
  getMenuPageApis,
  getMenuApiTree,
  getMenuGroups,
  addMenuGroup
})